package Sequence;

public class Test0701 {
}

class Solution0701_1 {
    public TreeNode insertIntoBST(TreeNode root, int val) {
        if (root == null) return new TreeNode(val);
        insert(root, val);
        return root;
    }

    public void insert(TreeNode root, int key) {
        if (key<root.val) {
            if (root.left==null) {
                root.left = new TreeNode(key);
            }else {
                insert(root.left, key);
            }
        }else {
            if (root.right==null) {
                root.right = new TreeNode(key);
            }else {
                insert(root.right, key);
            }
        }
    }
}
